package com.cloudcc.mobile.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RadioButton;
import android.widget.TextView;

import com.cloudcc.mobile.R;
import com.cloudcc.mobile.entity.addmicropost.Polls;

public class PollAdapter extends BaseAdapter{
	private List<Polls>  list;
	private Context context;
	public PollAdapter(List<Polls>  list,Context context){
		this.list=list;
		this.context=context;
	}
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Polls getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if(convertView==null){
			holder=new ViewHolder();
			convertView=LayoutInflater.from(context).inflate(R.layout.poll_item, null);
			holder.radio=(RadioButton) convertView.findViewById(R.id.radiotext);
			holder.countp=(TextView)convertView.findViewById(R.id.tvpp);
			convertView.setTag(holder);
		}else{
			holder=(ViewHolder) convertView.getTag();
		}
		final Polls poll=list.get(position);
		holder.radio.setText(poll.getOption());
		
		return convertView;
	}
	class ViewHolder{
		private RadioButton radio;
		private TextView countp;
	}

}
